package com.stox.client.http;

import java.util.List;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;

import com.stox.client.CountryClient;
import com.stox.dto.Country;
import com.stox.dto.web.Response;

@Component
public class CountryHttpClient extends AbstractHttpClient implements CountryClient {

	@Override
	@Cacheable("com.stox.dto.Country")
	public List<Country> findAll() {
		 return extract(getRestTemplate().exchange(getRootUrl()+"/countries", HttpMethod.GET, null, new ParameterizedTypeReference<Response<List<Country>>>() {}));
	}
	
}
